window.onload = function(){
	
	var times = document.querySelector('div.times'),
		hour  = times.querySelector('.h'),
		minute = times.querySelector('.m'),
		second = times.querySelector('.s');
	
	var hours = parseInt(hour.innerText),
		minutes = parseInt(minute.innerText),
		seconds = parseInt(second.innerText);
	console.log(hours);
	
	timer = window.setInterval(countDown, 1000);
	
	function countDown(){
		
		if(seconds == 0 && minutes == 0 && hours == 0){
			window.clearInterval(timer);
		}
		
		if(seconds >= 0){
			seconds--;
			if(seconds <= 0){
				if(minutes >= 0){
					minutes--;
					if(minutes <= 0){
						if(hours > 0){
							hours--;
							if(hours < 0){
								//window.clearInterval(timer);
							}
							minutes = 59;
							var hourText = '00';
							if(hours < 10){
								hourText = '0' + hours;
							}else{
								hourText = hours;
							}
							hour.innerText = hourText;
						}
						
					}
					seconds = 59;
					var minuteText = '00';
					if(minutes < 10){
						minuteText = '0' + minutes;
					}else{
						minuteText = minutes;
					}
					minute.innerText = minuteText;
				}
				
			}
			if(seconds <= 0){
				seconds = 0;
			}
			var secondText = '00';
			if(seconds < 10){
				secondText = '0' + seconds;
			}else{
				secondText = seconds;
			}
			
			second.innerText = secondText;
		}
		
	}
	
	
}